

from Crypto.Cipher import AES
import base64

# 不足16位的倍数就用空格补足为16位
def add_to_16(text):
    if len(text) % 16:
        add = 16 - (len(text) % 16)
    else:
        add = 0
    text = text+(b'\0' * add)
    return text

# 加密函数
def encrypt(text,key):
    key =add_to_16(key)
    mode = AES.MODE_ECB
    text = add_to_16(text)#补位
    cryptos = AES.new(key, mode,)
    cipher_text = cryptos.encrypt(text)
    return base64.b64encode(cipher_text).decode()

# 解密函数，去掉补足的空格用strip()
def decrypt(text,key):
    key = add_to_16(key)#补位
    mode = AES.MODE_ECB
    cryptos = AES.new(key, mode,)
    plain_text = cryptos.decrypt(base64.b64decode(text))
    return plain_text.rstrip(b'\0')

# if __name__ == '__main__':
#     e = encrypt("flag{}",'123')  # 加密
#     d = decrypt(e,'123')  # 解密
#     print("加密:", e)
#     print("解密:", d)

c="Kln/qZwlOsux+b/Gv0WsxkOec5E70dNhvczSLFs+0pkHaovEOBqUApBGBDBUrH08=="
import libnum
import gmpy2
for i in range(1,1000000):
   # try:
        tmp=str(i).zfill(6).encode()
        #tmp=libnum.n2s(i)
        m = decrypt(c, tmp)
        if b"DASCTF" in m:
            print(tmp)
            print(m)
            break
   # except:
   #      continue


